package com.xinbo.tuiyousuper.fragment;

import java.util.ArrayList;
import java.util.List;

import com.xinbo.tuiyousuper.R;
import com.xinbo.tuiyousuper.R.layout;
import com.xinbo.tuiyousuper.model.UserData;
import com.xinbo.tuiyousuper.utils.Constans;

import android.R.integer;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

/**
 * A simple {@link Fragment} subclass.
 *
 */
public class BlankFragment3 extends Fragment
{
	private List<UserData> list = new ArrayList<UserData>();
	private LayoutInflater inflater;
	private int []images ={R.drawable.fenlei01,R.drawable.fenlei02,R.drawable.fenlei03,R.drawable.fenlei04,R.drawable.fenlei05,R.drawable.fenlei06,R.drawable.fenlei07,R.drawable.fenlei08,R.drawable.fenlei09,R.drawable.fenlei10,R.drawable.fenlei11,R.drawable.fenlei12,R.drawable.fenlei13,R.drawable.fenlei14,R.drawable.fenlei15,R.drawable.fenlei16,R.drawable.fenlei17,R.drawable.fenlei18,R.drawable.fenlei19};
	public BlankFragment3()
	{
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	        Bundle savedInstanceState)
	{
		this.inflater=inflater;
		View layout = inflater.inflate(R.layout.fragment_blank_fragment3, container,
		        false);
		ListView mListView = (ListView) layout.findViewById(R.id.listView3_bg3);
		for (int i = 0; i <Constans.Text.FENLEI_TITLE.length; i++)
        {
			String title = Constans.Text.FENLEI_TITLE[i];
			String name = Constans.Text.FENLEI_NAME2[i];
			int image = images[i];
			list.add(new UserData(title, name, image));
        }
		MyAdapter adapter = new MyAdapter();
		mListView.setAdapter(adapter);
		return layout;
	}
	class MyAdapter extends BaseAdapter
	{

		@Override
        public int getCount()
        {
	        
	        return list.size();
        }

		@Override
        public Object getItem(int position)
        {
	        // TODO Auto-generated method stub
	        return null;
        }

		@Override
        public long getItemId(int position)
        {
	        // TODO Auto-generated method stub
	        return 0;
        }

		@Override
        public View getView(int position, View convertView, ViewGroup parent)
        {
			View layout=null;
			if (convertView==null)
            {
				layout = inflater.inflate(R.layout.listview_item, null);
	            convertView=layout;
            }else
            {
            	layout=convertView;
            }
            ImageView mImageView = (ImageView) layout.findViewById(R.id.iv_photo_bf3);	
            TextView tvTitle = (TextView) layout.findViewById(R.id.tv_title_bf3);
	        TextView tvName = (TextView) layout.findViewById(R.id.tv_name_bf3);
	        UserData userData = list.get(position);
	        tvTitle.setText(userData.getTitle());
	        tvName.setText(userData.getName());
	        mImageView.setImageResource(userData.getImage());
	        return layout ;
        }
		
	}
}
